package cn.stylefeng.guns.modular.business.frequency.orderstock.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.orderstock.service.OrderStockService;
import cn.stylefeng.guns.modular.business.frequency.orderstock.model.param.OrderStockParam;

import javax.annotation.Resource;

/**
 * 入库(验车操作记录) 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:16
 */
@RestController
public class OrderStockController {

    @Resource
    private OrderStockService orderStockService;

    /**
     * 分页查询入库(验车操作记录)
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderStock/page")
    @BusinessLog(title = "入库(验车操作记录)_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(OrderStockParam orderStockParam) {
        return new SuccessResponseData(orderStockService.page(orderStockParam));
    }

    /**
     * 获取全部入库(验车操作记录)
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderStock/list")
    @BusinessLog(title = "入库(验车操作记录)_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(OrderStockParam orderStockParam) {
        return new SuccessResponseData(orderStockService.list(orderStockParam));
    }

    /**
     * 查看详情入库(验车操作记录)
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderStock/detail")
    @BusinessLog(title = "入库(验车操作记录)_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(OrderStockParam.detail.class) OrderStockParam orderStockParam) {
        return new SuccessResponseData(orderStockService.detail(orderStockParam));
    }

    /**
     * 添加入库(验车操作记录)
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderStock/add")
    @BusinessLog(title = "入库(验车操作记录)_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(OrderStockParam.add.class) OrderStockParam orderStockParam) {
        orderStockService.add(orderStockParam);
        return new SuccessResponseData();
    }

    /**
     * 删除入库(验车操作记录)
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderStock/delete")
    @BusinessLog(title = "入库(验车操作记录)_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(OrderStockParam.delete.class) OrderStockParam orderStockParam) {
        orderStockService.delete(orderStockParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑入库(验车操作记录)
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderStock/edit")
    @BusinessLog(title = "入库(验车操作记录)_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(OrderStockParam.edit.class) OrderStockParam orderStockParam) {
        orderStockService.edit(orderStockParam);
        return new SuccessResponseData();
    }


}
